import React from 'react';
import {HashRouter, /*BrowserRouter,*/ withRouter, Redirect, Route, Switch} from 'react-router-dom';
import {LocaleProvider} from 'antd';
import zhCN from 'antd/lib/locale-provider/zh_CN';
import 'moment/locale/zh-cn';

//layout
import Layout from '@layout/public/index.jsx';

//page
import HelpManage from '@pages/help_manage/index.jsx';
import Home from '@pages/home/index.jsx';
import PartyActive from '@pages/party_active/index.jsx';
import PartyCheck from '@pages/party_check/index.jsx';
import PartyGraceful from '@pages/party_graceful/index.jsx';
import PartyHeart from '@pages/party_heart/index.jsx';
import PartyLearn from '@pages/party_learn/index.jsx';
import PartyManage from '@pages/party_manage/index.jsx';
import PartyMeet from '@pages/party_meet/index.jsx';
import PartyPay from '@pages/party_pay/index.jsx';
import SystemManage from '@pages/system_manage/index.jsx';
import VolManage from '@pages/volmanage/index.jsx';
import WorkLink from '@pages/work_link/index.jsx';


const PublicLayoutChild = (props) => {
    return (
        <Layout {...props}>
            <Switch>
                <Route path="/layout/partymanage" component={withRouter(PartyManage)}/>
                <Route path="/layout/partypay" component={withRouter(PartyPay)}/>
                <Route path="/layout/partycheck" component={withRouter(PartyCheck)}/>
                <Route path="/layout/partyactive" component={withRouter(PartyActive)}/>
                <Route path="/layout/partylearn" component={withRouter(PartyLearn)}/>
                <Route path="/layout/partymeet" component={withRouter(PartyMeet)}/>
                <Route path="/layout/volmanage" component={withRouter(VolManage)}/>
                <Route path="/layout/partyheart" component={withRouter(PartyHeart)}/>
                <Route path="/layout/helpmanage" component={withRouter(HelpManage)}/>
                <Route path="/layout/partygraceful" component={withRouter(PartyGraceful)}/>
                <Route path="/layout/worklink" component={withRouter(WorkLink)}/>
                <Route path="/layout/systemmanage" component={withRouter(SystemManage)}/>
                <Redirect from="/layout" to="/login "/>
            </Switch>
        </Layout>
    )
};

const pageRouter = () => {
    return (
        <LocaleProvider locale={zhCN}>
            <HashRouter>
                <Switch>
                    <Route path="/home" component={withRouter(Home)}/>
                    <Route path="/layout" render={(props) => <PublicLayoutChild {...props}/>}/>
                    <Redirect from="/" to="/home"/>
                </Switch>
            </HashRouter>
        </LocaleProvider>
    )
}

export default pageRouter;